/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ile.Modelo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

/**
 *
 * @author 
 */
@Entity
public class Marka implements Serializable{
     @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Long id;
    @Column
    private String nombreM;
    @Column
    private int cantidadM;
    @Column
    private int disponibleM;
    
    
    @OneToMany(mappedBy = "marka")
    private List<PedidoMaterial> pedidoMaterials;
    
    
    @ManyToOne (cascade = CascadeType.ALL)
    private Materiales material;

    public Marka() {
        
        pedidoMaterials= new ArrayList<PedidoMaterial>();
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getNombreM() {
        return nombreM;
    }

    public void setNombreM(String nombreM) {
        this.nombreM = nombreM;
    }

    public int getCantidadM() {
        return cantidadM;
    }

    public void setCantidadM(int cantidadM) {
        this.cantidadM = cantidadM;
    }

    public int getDisponibleM() {
        return disponibleM;
    }

    public void setDisponibleM(int disponibleM) {
        this.disponibleM = disponibleM;
    }

    public Materiales getMaterial() {
        return material;
    }

    public void setMaterial(Materiales material) {
        this.material = material;
    }

    public List<PedidoMaterial> getPedidoMaterials() {
        return pedidoMaterials;
    }

    public void setPedidoMaterials(List<PedidoMaterial> pedidoMaterials) {
        this.pedidoMaterials = pedidoMaterials;
    }
    
    
    
     public void agregarPM(PedidoMaterial pm){
         if((pm!= null&& !pedidoMaterials.contains(pm))){
             this.pedidoMaterials.add(pm);
             pm.setMarka(this);
             
             
         }
         
     }
    
}
